From a4270c33588bff131d57fa7a1a4f316dd2ce7c7f Mon Sep 17 00:00:00 2001 From: "jws@cairnwell.research" Date: Wed, 9 Apr 2003 10:38:33 +0000 Subject: [PATCH] bitkeeper revision 1.160.1.3 (3e93f829-ne467JH-6UdjBVdjZRCgw) a few tricks to avoid memory problems. BUG remains: there is nothing to stop the kernel stack growing too big (i.e. to nearly 8k); if it does, it will overwrite the idle0_task task struct which it shares a page with. If you see a page fault in the scheduler (prev_task, next_task corrupted), suspect this bug. --- xen/arch/i386/ioremap.c | 4 ++++ xen/drivers/pci/pci.c | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/xen/arch/i386/ioremap.c b/xen/arch/i386/ioremap.c index 4ed7ba438d..717c69c980 100644 --- a/xen/arch/i386/ioremap.c +++ b/xen/arch/i386/ioremap.c @@ -50,6 +50,10 @@ void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flag if (phys_addr >= 0xA0000 && last_addr < 0x100000) return phys_to_virt(phys_addr); + if(remap_base + size > IOREMAP_VIRT_END) { + printk("ioremap: going past end of reserved space!\n"); + return NULL; + } #if 0 /* * Don't allow anybody to remap normal RAM that we're using.. diff --git a/xen/drivers/pci/pci.c b/xen/drivers/pci/pci.c index 134e3e2c83..87a64d7f82 100644 --- a/xen/drivers/pci/pci.c +++ b/xen/drivers/pci/pci.c @@ -1505,21 +1505,26 @@ unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus) { unsigned int devfn, max, pass; struct list_head *ln; - struct pci_dev *dev, dev0; + struct pci_dev *dev, *dev0; DBG("Scanning bus %02x\n", bus->number); max = bus->secondary; /* Create a device template */ - memset(&dev0, 0, sizeof(dev0)); - dev0.bus = bus; - dev0.sysdata = bus->sysdata; + dev0 = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); + if(!dev0) { + panic("Out of memory scanning PCI bus!\n"); + } + memset(dev0, 0, sizeof(struct pci_dev)); + dev0->bus = bus; + dev0->sysdata = bus->sysdata; /* Go find them, Rover! */ for (devfn = 0; devfn < 0x100; devfn += 8) { - dev0.devfn = devfn; - pci_scan_slot(&dev0); + dev0->devfn = devfn; + pci_scan_slot(dev0); } + kfree(dev0); /* * After performing arch-dependent fixup of the bus, look behind -- 2.30.2